@echo off
REM Python环境迁移脚本 - 将Python用户包路径从C盘迁移到F盘

echo =================================================
echo Python环境迁移脚本
echo 从C盘迁移到F盘
echo =================================================

REM 1. 设置新的Python用户基础路径
echo 设置PYTHONUSERBASE环境变量...
setx PYTHONUSERBASE "F:\Python-Environment\Roaming\Python" /M
if %errorlevel% neq 0 (
    echo 需要管理员权限设置系统环境变量，尝试用户级设置...
    setx PYTHONUSERBASE "F:\Python-Environment\Roaming\Python"
)

REM 2. 设置conda包缓存路径
echo 设置conda包缓存路径...
setx CONDA_PKGS_DIRS "F:\Python-Environment\conda-cache" /M
if %errorlevel% neq 0 (
    setx CONDA_PKGS_DIRS "F:\Python-Environment\conda-cache"
)

REM 3. 创建conda配置文件
echo 创建conda配置文件...
if not exist "C:\Users\Administrator\.condarc" (
    echo # Conda配置文件 > "C:\Users\Administrator\.condarc"
)

echo 将以下配置添加到.condarc文件:
echo pkgs_dirs:
echo   - F:\Python-Environment\conda-cache
echo   - F:\ProgramData\anaconda3\pkgs
echo.
echo envs_dirs:
echo   - F:\ProgramData\anaconda3\envs
echo.

REM 4. 创建Python启动脚本
echo 创建Python启动脚本...

REM 创建启动bat文件
echo @echo off > "F:\Python-Environment\python-env.bat"
echo set PYTHONUSERBASE=F:\Python-Environment\Roaming\Python >> "F:\Python-Environment\python-env.bat"
echo set CONDA_PKGS_DIRS=F:\Python-Environment\conda-cache >> "F:\Python-Environment\python-env.bat"
echo set PATH=F:\Python-Environment\Roaming\Python\Python310\Scripts;%%PATH%% >> "F:\Python-Environment\python-env.bat"
echo conda activate base >> "F:\Python-Environment\python-env.bat"
echo cmd >> "F:\Python-Environment\python-env.bat"

echo =================================================
echo 环境变量设置完成！
echo.
echo 下一步操作：
echo 1. 重启命令提示符或重新登录系统
echo 2. 运行: F:\Python-Environment\python-env.bat
echo 3. 验证环境: python -m site
echo =================================================

pause